#include "PlayingState.h";

#include "../Managers/GameService.h"
#include "../Managers/WindowManager.h"
#include "../Managers/StateManager.h"
#include "../Managers/LevelManager.h"

//-------------------------------------------------------------------------------------------
PlayingState::PlayingState()
{	
}

//-------------------------------------------------------------------------------------------
PlayingState::~PlayingState()
{
}

//-------------------------------------------------------------------------------------------
 void PlayingState::Begin()
{
	m_pStateManager = GameService::GetInstance()->GetStateManager();
	m_pLevelManager = GameService::GetInstance()->GetLevelManager();
}

//-------------------------------------------------------------------------------------------
void PlayingState::End()
{
}

//-------------------------------------------------------------------------------------------
void PlayingState::Tick(float DeltaTime)
{
 	WindowManager* pWindowManager = GameService::GetInstance()->GetWindowManager();
	sf::RenderWindow* pWindow = pWindowManager->GetWindow();

	sf::Text text("     Esc - Menu State.     Any Key - Begin");
	text.setPosition(0, 0);
	pWindow->draw(text);
}

//-------------------------------------------------------------------------------------------
void PlayingState::OnInput(sf::Event::KeyEvent* pKeyEvent, bool keyDown)
{
	switch (pKeyEvent->code)
	{
	case sf::Keyboard::Escape:
		{
			if (!keyDown)
				m_pStateManager->SetState(StateManager::GameStates::STATE_MENU);

		}break;
	default:
		{
			m_pLevelManager->BeginGame();
		}break;
	}
}